package march.test_3_10;

import java.util.Scanner;

public class testmain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            long n = scanner.nextInt();
            System.out.println(result(n));
        }
    }
    public static long result(long n) {
        long  count = 0;
        long tmp = n;
        while (tmp / 10 != 0) {
            count += tmp % 10;
            tmp /= 10;
            if(tmp < 10) {
                tmp = tmp + count;
                count = 0;
            }
        }
        return tmp;
    }
}
